# -*- coding: utf-8 -*-

import re 

class DnsBruteSrvs():
	addrs = []
	counters = {}
	counter = 0
	def __init__(self, addr):
		if re.match(r"(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})", addr) is not None:
			self.addrs.append(addr)
			self.counters[addr] = 0
		else:
			fh = open(addr)
			addrs = list(set(fh.readlines()))
			for addr in addrs:
				if len(addr.strip()):
					self.addrs.append(addr.strip())
					self.counters[addr.strip()] = 0
			fh.close()
	
	def get(self):
		addr = self.addrs[self.counter if self.counter < len(self.addrs) else self.counter%len(self.addrs)]
		self.counters[addr] = self.counters.get(addr, 0) + 1
		self.counter += 1
		return addr
		
	def get_counters(self):
		return self.counters